<template>
  <div>
    <h1>欢迎, {{ userStore.userInfo.fullName || userStore.userInfo.username }}!</h1>
    <p>你已成功登录自学考试管理系统。</p>
    <p>你的角色是: {{ userStore.userInfo.role }}</p>
    <el-button type="danger" @click="handleLogout">退出登录</el-button>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useUserStore } from '@/store/user'

const router = useRouter()
const userStore = useUserStore()

const handleLogout = async () => {
  await userStore.logout()
  router.push('/login')
}
</script>